/**
 * Created by changshuiwang on 2016/7/28.
 */
$(function(){
    $(".upload-score").click(function(){
        layer.open({
            type:2,
            title:'上传成绩',
            area: ['60%', '80%'],
            content:'/score/add',
            /*            end : function(){ //层彻底关闭后执行的回调
             window.location.reload();
             }*/
        })
    });
    $(".update-score").submit(function(){
        var data=$(this).serialize();
        //data=data+"&submit=0";
        $.ajax({
            url:'/score/add',
            type:"POST",
            data:data,
            dataType:"json",
            success:function(msg){
                if(msg.status=="success"){
                    alert("上传成功");
                    window.top.location.reload();
                }else{
                    alert(msg.error);
                }
            }
        });
        return false;
    });
    $(".glyphicon-pencil").click(function(){
        var status=$(this).attr('status');
        var id=$(this).attr('id');
        if(status==0){
            alert("该学生已删除，不能修改成绩");
        }else{
            layer.open({
                type:2,
                title:"修改成绩",
                area:['60%', '80%'],
                content:'/score/modify?id='+id,
            });
        }
    });
    $(".modify-score").submit(function(){
        var data=$("input[name='stu_id']").val();
        data='stu_id='+data;
        data=data+'&'+$(this).serialize();
        $.ajax({
            url:'/score/modify',
            type:"POST",
            data:data,
            dataType:"json",
            success:function(msg){
                if(msg.status=="success"){
                    alert("修改成功");
                    window.top.location.reload();
                }else{
                    alert(msg.error);
                }
            }
        });
        return false;
    })
})
